package com.dtx.factory.myself.myidcard;

import com.dtx.factory.gongyoude.framework.Factory;
import com.dtx.factory.gongyoude.framework.Product;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;

public class MyIDCardFactory extends Factory {

    private ConcurrentHashMap<String,Object> database = new ConcurrentHashMap<>();

    private List<Object> owners = new ArrayList<>();

    protected Integer number = 100;

    @Override
    protected synchronized Product createProduct(String owner) {
        return new MyIDCard(owner,number++);
    }

    @Override
    protected void registerProduct(Product product) {
       MyIDCard card = (MyIDCard) product;
       database.put(String.valueOf(card.getNumber()),card.getOwner());
    }

    public ConcurrentHashMap getDatabase(){
        return  database;
    }
}
